package hy.controller;

import hy.beans.Item;
import hy.beans.Order;
import hy.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashSet;
import java.util.Set;

@Controller
public class OrderCtrl {
    @Autowired
    OrderService service;

    @RequestMapping("/order")
    @ResponseBody
    public String test() throws Exception {
        Order o=new Order();
        o.setOrderNo("abcdd");
        o.setPhone("139");
        o.setStatus(1);

        //订单明细
        Set set= new HashSet();
        set.add(new Item(o.getOrderNo(),1,3));
        set.add(new Item(o.getOrderNo(),2,2));
        o.setItems(set);

        service.processOrder(o);
        return "订单产生成功";
    }
}